package com.ly.web.controller.erp;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.AssetsStatusEntity;
import com.ly.heart.service.IAssetsStatusService;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 资产状态Controller
 *
 * @author cxl
 * @date 2024-09-03
 */
@Api(value = "资产状态", tags = "资产状态")
@RestController
@RequestMapping("/heart/AssetsStatus")
public class AssetsStatusController extends BaseController {

    @Resource
    private IAssetsStatusService assetsStatusService;


    /**
     * 查询资产状态列表
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsStatus:list')")
    @PostMapping("/list")
    @ApiOperation("查询资产状态列表")
    public AjaxResult getAssetsStatusList(@RequestBody AssetsStatusEntity assetsStatus){
        return assetsStatusService.getAssetsStatusList(assetsStatus);
    }

    /**
     * 获取资产状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsStatus:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取资产状态详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(assetsStatusService.selectAssetsStatusEntityById(id));
    }

    /**
     * 新增资产状态
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsStatus:add')")
    @Log(title = "资产状态", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增资产状态")
    public AjaxResult add(@RequestBody AssetsStatusEntity assetsStatus)
    {
        return toAjax(assetsStatusService.insertAssetsStatusEntity(assetsStatus));
    }

    /**
     * 修改资产状态
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsStatus:edit')")
    @Log(title = "资产状态", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改资产状态")
    public AjaxResult edit(@RequestBody AssetsStatusEntity assetsStatusEntity)
    {
        return toAjax(assetsStatusService.updateAssetsStatusEntity(assetsStatusEntity));
    }

    /**
     * 删除资产状态
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsStatus:remove')")
    @Log(title = "资产状态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除资产状态")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(assetsStatusService.deleteAssetsStatusEntityByIds(ids));
    }

    /**
     * 导出资产状态列表
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsStatus:export')")
    @Log(title = "资产状态", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出资产状态列表")
    public AjaxResult export(AssetsStatusEntity assetsStatusEntity)
    {
        List<AssetsStatusEntity> list = assetsStatusService.selectAssetsStatusEntityList(assetsStatusEntity);
        ExcelUtil<AssetsStatusEntity> util = new ExcelUtil<AssetsStatusEntity>(AssetsStatusEntity.class);
        return util.exportExcel(list, "AssetsStatus");
    }

    @Log (title = "禁用/反禁用资产状态", businessType = BusinessType.OTHER)
    @PostMapping ("/disabled")
    @ApiOperation ("禁用/反禁用资产状态")
    public AjaxResult disabled (@RequestParam("id") String id) {
        return assetsStatusService.disable ( id );
    }


}
